package zdream.pmfield.stage.message;

import java.util.Objects;

import zdream.pmfield.stage.buff.foe.FoeStageBuff;
import zdream.pmfield.stage.buff.StageBuff;
import zdream.pmfield.stage.object.FoeActor;

/**
 * @author Zdream
 * @date 2023-11-21
 * @since 0.0.1
 */
public class FoeAddBuffMessage extends StageMessage {
	public final FoeActor foe;
	public final FoeStageBuff buff;
	public boolean success = true;
	public StageBuff<?> rejectBy;

	public FoeAddBuffMessage(FoeStageBuff buff) {
		this.type = StageMessageType.REPORT;
		this.buff = Objects.requireNonNull(buff);
		this.foe = buff.target;
	}

	public FoeAddBuffMessage(FoeActor.ReceiveBuffReport report) {
		this(report.buff);
		this.success = report.accept;
		this.rejectBy = report.rejectBy;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(64);
		builder.append("[FB]").append(' ');
		foe.appendStringWithoutHp(builder);
		builder.append(' ');
		builder.append(success ? "增加" : "避免");
		builder.append("状态").append(':').append(' ').append(buff);

		if (!success) {
			builder.append(',').append(' ').append("原因是被").append(rejectBy).append("阻止了");
		}
		return builder.toString();
	}
}
